package pe.com.bn.sach.dao.impl;

import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;
import pe.com.bn.sach.dao.ItemDAO;
import pe.com.bn.sach.domain.Bnchf06Tabla;
import pe.com.bn.sach.domain.Bnchf07Item;
import pe.com.bn.sach.domain.Bnchf09Profesion;
import pe.com.bn.sach.domain.Bnchf10Instruccion;

public class ItemImpl implements ItemDAO {

	
	protected SqlMapClient sqlMap = null;
	
	public void setSqlMap(SqlMapClient sqlMap) {
		this.sqlMap = sqlMap;
	}

	public List listItem(Bnchf07Item bnchf07Item) throws Exception{
	
		return sqlMap.queryForList("sqlItem.listaItem",bnchf07Item);
	}
	
	public Bnchf07Item getItem(Bnchf07Item bnchf07Item) throws Exception{

		return (Bnchf07Item)sqlMap.queryForObject("sqlItem.getItem",bnchf07Item);
	}
	
	public void GuardaItem(Bnchf07Item bnchf07Item)throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.insert("sqlItem.GuardaItem",bnchf07Item);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
	}
	
	
	/**********************PROFESION**************************/
	
	public List listProfesion(Bnchf09Profesion bnchf09Profesion) throws Exception{
		return sqlMap.queryForList("sqlItem.listaProfesion",bnchf09Profesion);
	}
	
	/**********************INSTRUCCION**************************/
	
	public List lisInstruccion(Bnchf10Instruccion bnchf10Instruccion) throws Exception{
		return sqlMap.queryForList("sqlItem.listaInstruccion",bnchf10Instruccion);
	}
	
	/**********************IParenesco*************************/
	
	public List lisParentesco() throws Exception{
		return sqlMap.queryForList("sqlItem.listaParentesco");
	}
	
	/**********************Bancos **************************/
	
	public List listBancos(Bnchf07Item bnchf07Item) throws Exception{
		return sqlMap.queryForList("sqlItem.listaBancos",bnchf07Item);
	}
	
	
	public void guardarProfesion(Bnchf09Profesion bnchf09Profesion) throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.update("sqlItem.guardarProfesion",bnchf09Profesion);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
		
	}
	public void actualizarProfesion(Bnchf09Profesion bnchf09Profesion) throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.update("sqlItem.actualizarProfesion",bnchf09Profesion);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}

	}
	public List buscarProfesion(Bnchf09Profesion bnchf09Profesion) throws Exception{
		return sqlMap.queryForList("sqlItem.buscarProfesion",bnchf09Profesion);
	}
	public void guardarTabla(Bnchf06Tabla bnchf06Tabla) throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.insert("sqlItem.guardarTabla",bnchf06Tabla);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
	}
	public void actualizarTabla(Bnchf06Tabla bnchf06Tabla) throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.update("sqlItem.actualizarTabla",bnchf06Tabla);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
		
	}
	public List buscarTabla(Bnchf06Tabla bnchf06Tabla) throws Exception{
		return sqlMap.queryForList("sqlItem.buscarTabla",bnchf06Tabla);
		}
	public List listarTabla(Bnchf06Tabla bnchf06Tabla) throws Exception{
		return sqlMap.queryForList("sqlItem.listarTabla",bnchf06Tabla);
		}
	public void guardarItem(Bnchf07Item bnchf07Item) throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.insert("sqlItem.guardarItem",bnchf07Item);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
	}
	public void actualizarItem(Bnchf07Item bnchf07Item) throws Exception{

		try{
			sqlMap.startTransaction();
			sqlMap.update("sqlItem.actualizarItem",bnchf07Item);	
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
	}
	public List buscarItem(Bnchf07Item bnchf07Item) throws Exception{
		return sqlMap.queryForList("sqlItem.buscarItem",bnchf07Item);
		}
	public List listarItem(Bnchf07Item bnchf07Item) throws Exception{
		return sqlMap.queryForList("sqlItem.listarItem",bnchf07Item);
		}
	
	
}
